package com.pizzastudio;

import java.io.Serializable;

public class BasicNameValuePair implements Cloneable, Serializable {

    private static final long serialVersionUID = -6437800749411518984L;

    private final String name;
    private final String value;

    /**
     * Default Constructor taking a name and a value. The value may be null.
     * 
     * @param name The name.
     * @param value The value.
     */
    public BasicNameValuePair(final String name, final String value) {
        super();
        if (name == null) {
            throw new IllegalArgumentException("Name may not be null");
        }
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return this.name;
    }

    public String getValue() {
        return this.value;
    }

    public String toString() {
        // don't call complex default formatting for a simple toString
        
        if (this.value == null) {
            return name;
        } else {
            int len = this.name.length() + 1 + this.value.length();
            StringBuffer buffer = new StringBuffer(len);
            buffer.append(this.name);
            buffer.append("=");
            buffer.append(this.value);
            return buffer.toString();
        }
    }

    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
 
}